package com.novell.sasl.client;

import java.util.Iterator;
import org.apache.harmony.javax.security.sasl.SaslException;

class ResponseAuth
{
  private String m_responseValue = null;

  ResponseAuth(byte[] paramArrayOfByte)
    throws SaslException
  {
    DirectiveList localDirectiveList = new DirectiveList(paramArrayOfByte);
    try
    {
      localDirectiveList.parseDirectives();
      checkSemantics(localDirectiveList);
      return;
    }
    catch (SaslException localSaslException)
    {
    }
  }

  void checkSemantics(DirectiveList paramDirectiveList)
    throws SaslException
  {
    Iterator localIterator = paramDirectiveList.getIterator();
    while (true)
    {
      ParsedDirective localParsedDirective;
      do
      {
        if (!(localIterator.hasNext()))
        {
          if (this.m_responseValue != null)
            return;
          throw new SaslException("Missing response-auth directive.");
        }
        localParsedDirective = (ParsedDirective)localIterator.next();
      }
      while (!(localParsedDirective.getName().equals("rspauth")));
      this.m_responseValue = localParsedDirective.getValue();
    }
  }

  public String getResponseValue()
  {
    return this.m_responseValue;
  }
}